-- ----------------------------
-- Table structure for datasource_config
-- ----------------------------
DROP TABLE IF EXISTS `datasource_config`;
CREATE TABLE `datasource_config`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键编号',
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '数据源名称',
  `url` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '数据源连接URL',
  `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '用户名',
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '密码',
  `type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '数据库类型',
  `enabled` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否启用',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
  `sort` int NULL DEFAULT 0 COMMENT '排序',
  `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_name` (`name`) USING BTREE COMMENT '数据源名称唯一索引'
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '数据源配置表';

-- ----------------------------
-- Records of datasource_config
-- ----------------------------
BEGIN;
INSERT INTO `datasource_config` (`id`, `name`, `url`, `username`, `password`, `type`, `enabled`, `remark`, `sort`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES 
(1, '示例MySQL数据库', 'jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true', 'root', '123456', 'MYSQL', b'1', '示例数据源配置，请根据实际情况修改', 1, '1', '2024-01-01 12:00:00', '1', '2024-01-01 12:00:00', b'0', 1);
COMMIT;

-- ----------------------------
-- Insert menu data for datasource module
-- ----------------------------
BEGIN;
-- 插入数据源管理主菜单
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES 
(2800, '数据源管理', '', 1, 9, 2, 'datasource', 'fa:database', NULL, NULL, 0, b'1', b'1', b'1', '1', '2024-01-01 12:00:00', '1', '2024-01-01 12:00:00', b'0');

-- 插入数据源配置子菜单
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES 
(2801, '数据源配置', 'datasource:config:query', 2, 1, 2800, 'config', 'fa:cogs', 'datasource/config/index', 'DataSourceConfig', 0, b'1', b'1', b'1', '1', '2024-01-01 12:00:00', '1', '2024-01-01 12:00:00', b'0');

-- 插入数据源配置按钮
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES 
(2802, '数据源查询', 'datasource:config:query', 3, 1, 2801, '', '', '', '', 0, b'1', b'1', b'1', '1', '2024-01-01 12:00:00', '1', '2024-01-01 12:00:00', b'0'),
(2803, '数据源创建', 'datasource:config:create', 3, 2, 2801, '', '', '', '', 0, b'1', b'1', b'1', '1', '2024-01-01 12:00:00', '1', '2024-01-01 12:00:00', b'0'),
(2804, '数据源更新', 'datasource:config:update', 3, 3, 2801, '', '', '', '', 0, b'1', b'1', b'1', '1', '2024-01-01 12:00:00', '1', '2024-01-01 12:00:00', b'0'),
(2805, '数据源删除', 'datasource:config:delete', 3, 4, 2801, '', '', '', '', 0, b'1', b'1', b'1', '1', '2024-01-01 12:00:00', '1', '2024-01-01 12:00:00', b'0'),
(2806, '数据源导出', 'datasource:config:export', 3, 5, 2801, '', '', '', '', 0, b'1', b'1', b'1', '1', '2024-01-01 12:00:00', '1', '2024-01-01 12:00:00', b'0'),
(2807, '数据源切换', 'datasource:config:switch', 3, 6, 2801, '', '', '', '', 0, b'1', b'1', b'1', '1', '2024-01-01 12:00:00', '1', '2024-01-01 12:00:00', b'0');

-- 插入数据源测试子菜单  
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES 
(2808, '数据源测试', 'datasource:test:query', 2, 2, 2800, 'test', 'fa:flask', 'datasource/test/index', 'DataSourceTest', 0, b'1', b'1', b'1', '1', '2024-01-01 12:00:00', '1', '2024-01-01 12:00:00', b'0');

COMMIT;